package com.yorick.common.controller;

import com.yorick.common.Result.SimpleFactory.ResultFactory;
import com.yorick.common.dao.SecurityMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @program: CommonController
 * @description: 公共接口模块，只要在IP白名单以内的人都能访问
 * @author: Yorick
 * @create: 25/7/2022
**/
@Slf4j
@Controller
@RequestMapping("common")
public class CommonController {

    @Resource
    SecurityMapper securityMapper;

    @RequestMapping(value = "clearCache", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> clearCache(){
        securityMapper.clearCache();
        return ResultFactory.success().display();
    }

    @RequestMapping(value = "apiHealth", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> apiHealth(){
        return ResultFactory.success().display();
    }
}
